package com.example.java_gobang2.game;

import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

import java.util.concurrent.ConcurrentHashMap;

@Component
public class OnlineUserManager {
    private ConcurrentHashMap<Integer, WebSocketSession> gameHall = new ConcurrentHashMap<>();
    private ConcurrentHashMap<Integer, WebSocketSession> gameRoom = new ConcurrentHashMap<>();


    public void setGameHall(int userId, WebSocketSession session) {
        gameHall.put(userId,session);
    }

    public WebSocketSession getGameHall(int userId) {
        return gameHall.get(userId);
    }

    public void removeGameHall(int userId) {
        gameHall.remove(userId);
    }

    public void setGameRoom(int userId,WebSocketSession session) {
        gameRoom.put(userId,session);
    }

    public void removeRoom(int userId) {
        gameRoom.remove(userId);
    }

    public WebSocketSession getGameRoom(int userId) {
        return gameRoom.get(userId);
    }
}
